package com.sojson.controller.po;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.sojson.result.Result;
import com.sojson.util.ToolsUtil;

/**
 * 文件控制器
 * 
 * @author liu
 * @date 2021-03-18
 */
// @Api(tags = "文件管理")
// @RestController
// @RequestMapping("/fileMove")
public class FileMoveController {

    /**
     * 上传头像
     * 
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadHead")
    public Result<?> uploadHead(@RequestParam String filePath) throws Exception {
        return ToolsUtil.upload(filePath, ToolsUtil.HEAD_IMG_PATH, ToolsUtil.IMG_WHITE_LIST, ToolsUtil.IMG_SIZE);
    }

    /**
     * 上传企业资质照片
     * 
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadBusinessCert")
    public Result<?> uploadBusinessCert(@RequestParam String filePath) throws Exception {
        return ToolsUtil.upload(filePath, ToolsUtil.BUSINESS_CERT_IMG_PATH, ToolsUtil.IMG_WHITE_LIST,
            ToolsUtil.IMG_SIZE);
    }

    /**
     * 上传商品分类缩略图
     * 
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadGoodCateThumb")
    public Result<?> uploadGoodCateThumb(@RequestParam String filePath) throws Exception {
        return ToolsUtil.upload(filePath, ToolsUtil.GOOD_CATE_THUMB, ToolsUtil.IMG_WHITE_LIST, ToolsUtil.IMG_SIZE);
    }

    /**
     * 上传商品缩略图
     * 
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadGoodThumb")
    public Result<?> uploadGoodThumb(@RequestParam String filePath) throws Exception {
        return ToolsUtil.upload(filePath, ToolsUtil.GOOD_THUMB, ToolsUtil.IMG_WHITE_LIST, ToolsUtil.IMG_SIZE);
    }

    /**
     * 上传商品详情轮播图
     * 
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadGoodImages")
    public Result<?> uploadGoodImages(@RequestParam String filePath) throws Exception {
        return ToolsUtil.upload(filePath, ToolsUtil.GOOD_IMAGES, ToolsUtil.IMG_WHITE_LIST, ToolsUtil.IMG_SIZE);
    }

    /**
     * 上传商品规格明细缩略图
     * 
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadGoodSpecsAttrThumb")
    public Result<?> uploadGoodSpecsAttrThumb(@RequestParam String filePath) throws Exception {
        return ToolsUtil.upload(filePath, ToolsUtil.GOOD_SPECS_ATTR_THUMB, ToolsUtil.IMG_WHITE_LIST,
            ToolsUtil.IMG_SIZE);
    }

    /**
     * 上传商品规格明细缩略图
     * 
     * @param file
     * @return
     * @throws Exception
     */
    @PostMapping("/uploadComment")
    public Result<?> uploadComment(@RequestParam String filePath) throws Exception {
        return ToolsUtil.upload(filePath, ToolsUtil.COMMENT_IMG_PATH, ToolsUtil.IMG_WHITE_LIST, ToolsUtil.IMG_SIZE);
    }

}